﻿namespace ACCOUNTING.LVY.Business
{
    using ACCOUNTING;
    using Microsoft.VisualBasic.CompilerServices;
    using System;
    using System.Data;
    using System.Windows.Forms;

    public class clsNhapKhoChiTietDichVu
    {
        private double mDonGia = 0.0;
        private double mDonGiaNT = 0.0;
        private string mKhoa = "";
        private string mKhoaDichVu = "";
        private string mKhoaPhieuNhap = "";
        private string mKhoaTKChiPhi = "";
        private string mKhoaDoiTuongTapHopChiPhi = "";
        private string mTenDoiTuongTapHopChiPhi = "";
        private string mKhoaThanhPham = "";
        private string mTenThanhPham = "";
        private string mMaDichVu = "";
        private double mSoLuong = 0.0;
        private string mTenDichVu = "";
        private double mTienBan = 0.0;
        private double mTienBanNT = 0.0;
        private double mTienChietKhau = 0.0;
        private double mTienChietKhauNT = 0.0;
        private double mTienThue = 0.0;
        private double mTienThueNT = 0.0;
        private int mTyLeChietKhau = 0;
        private int mTyLeThue = 0;

        public bool Load(string pKhoa)
        {
            bool flag=false;
            try
            {
                string commandText = "SELECT * FROM BH_HoaDonChiTietDichVu WHERE Khoa = '" + pKhoa + "'";
                IDataReader dataReader = DBHelper.ExecuteReader(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]);
                if (dataReader.Read())
                {
                    this.mKhoa = Conversions.ToString(modGeneral.GetValue(dataReader, 0, modGeneral.typeOfColumn.GetString));
                    this.mKhoaPhieuNhap = Conversions.ToString(modGeneral.GetValue(dataReader, 1, modGeneral.typeOfColumn.GetString));
                    this.mKhoaDichVu = Conversions.ToString(modGeneral.GetValue(dataReader, 2, modGeneral.typeOfColumn.GetString));
                    this.mMaDichVu = Conversions.ToString(modGeneral.GetValue(dataReader, 3, modGeneral.typeOfColumn.GetString));
                    this.mTenDichVu = Conversions.ToString(modGeneral.GetValue(dataReader, 4, modGeneral.typeOfColumn.GetString));
                    this.mSoLuong = Conversions.ToDouble(modGeneral.GetValue(dataReader, 5, modGeneral.typeOfColumn.GetDecimal));
                    this.mDonGiaNT = Conversions.ToDouble(modGeneral.GetValue(dataReader, 6, modGeneral.typeOfColumn.GetDecimal));
                    this.mDonGia = Conversions.ToDouble(modGeneral.GetValue(dataReader, 7, modGeneral.typeOfColumn.GetDecimal));
                    this.mTienBanNT = Conversions.ToDouble(modGeneral.GetValue(dataReader, 8, modGeneral.typeOfColumn.GetDecimal));
                    this.mTienBan = Conversions.ToDouble(modGeneral.GetValue(dataReader, 9, modGeneral.typeOfColumn.GetDecimal));
                    this.mTyLeChietKhau = Conversions.ToInteger(modGeneral.GetValue(dataReader, 10, modGeneral.typeOfColumn.GetInt32));
                    this.mTienChietKhauNT = Conversions.ToDouble(modGeneral.GetValue(dataReader, 11, modGeneral.typeOfColumn.GetDecimal));
                    this.mTienChietKhau = Conversions.ToDouble(modGeneral.GetValue(dataReader, 12, modGeneral.typeOfColumn.GetDecimal));
                    this.mTyLeThue = Conversions.ToInteger(modGeneral.GetValue(dataReader, 13, modGeneral.typeOfColumn.GetInt32));
                    this.mTienThueNT = Conversions.ToDouble(modGeneral.GetValue(dataReader, 14, modGeneral.typeOfColumn.GetDecimal));
                    this.mTienThue = Conversions.ToDouble(modGeneral.GetValue(dataReader, 15, modGeneral.typeOfColumn.GetDecimal));
                    this.mKhoaTKChiPhi = Conversions.ToString(modGeneral.GetValue(dataReader, 0x10, modGeneral.typeOfColumn.GetString));
                    this.mKhoaDoiTuongTapHopChiPhi = Conversions.ToString(modGeneral.GetValue(dataReader, 16, modGeneral.typeOfColumn.GetString));
                    this.mTenDoiTuongTapHopChiPhi = Conversions.ToString(modGeneral.GetValue(dataReader, 17, modGeneral.typeOfColumn.GetString));
                    this.mKhoaThanhPham = Conversions.ToString(modGeneral.GetValue(dataReader, 18, modGeneral.typeOfColumn.GetString));
                    this.mTenThanhPham = Conversions.ToString(modGeneral.GetValue(dataReader, 19, modGeneral.typeOfColumn.GetString));
                }
                dataReader.Close();
                flag = true;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                flag = false;
                ProjectData.ClearProjectError();
                return flag;
                ProjectData.ClearProjectError();
            }
            return flag;
        }

        public bool Save()
        {
            bool flag=false;
            IDataParameter[] commandParameters = new IDataParameter[0x15];
            try
            {
                commandParameters[0] = DBHelper.createParameter("@Khoa", DbType.Int64, ParameterDirection.Input, this.mKhoa);
                commandParameters[1] = DBHelper.createParameter("@KhoaPhieuNhap", DbType.Int64, ParameterDirection.Input, this.mKhoaPhieuNhap);
                commandParameters[2] = DBHelper.createParameter("@KhoaDichVu", DbType.Int64, ParameterDirection.Input, this.mKhoaDichVu);
                commandParameters[3] = DBHelper.createParameter("@MaDichVu", DbType.Int64, ParameterDirection.Input, this.mMaDichVu);
                commandParameters[4] = DBHelper.createParameter("@TenDichVu", DbType.Int64, ParameterDirection.Input, this.mTenDichVu);
                commandParameters[5] = DBHelper.createParameter("@SoLuong", DbType.Date, ParameterDirection.Input, this.mSoLuong);
                commandParameters[6] = DBHelper.createParameter("@DonGiaNT", DbType.Date, ParameterDirection.Input, this.mDonGiaNT);
                commandParameters[7] = DBHelper.createParameter("@DonGia", DbType.Date, ParameterDirection.Input, this.mDonGia);
                commandParameters[8] = DBHelper.createParameter("@TienBanNT", DbType.Date, ParameterDirection.Input, this.mTienBanNT);
                commandParameters[9] = DBHelper.createParameter("@TienBan", DbType.Date, ParameterDirection.Input, this.mTienBan);
                commandParameters[10] = DBHelper.createParameter("@TyLeChietKhau", DbType.Double, ParameterDirection.Input, this.mTyLeChietKhau);
                commandParameters[11] = DBHelper.createParameter("@TienChietKhauNT", DbType.Date, ParameterDirection.Input, this.mTienChietKhauNT);
                commandParameters[12] = DBHelper.createParameter("@TienChietKhau", DbType.Date, ParameterDirection.Input, this.mTienChietKhau);
                commandParameters[13] = DBHelper.createParameter("@TyLeThue", DbType.Double, ParameterDirection.Input, this.mTyLeThue);
                commandParameters[14] = DBHelper.createParameter("@TienThueNT", DbType.Date, ParameterDirection.Input, this.mTienThueNT);
                commandParameters[15] = DBHelper.createParameter("@TienThue", DbType.Date, ParameterDirection.Input, this.mTienThue);
                commandParameters[0x10] = DBHelper.createParameter("@KhoaTKChiPhi", DbType.Int64, ParameterDirection.Input, this.mKhoaTKChiPhi);
                commandParameters[0x11] = DBHelper.createParameter("@KhoaDoiTuongTapHopChiPhi", DbType.Int64, ParameterDirection.Input, this.mKhoaDoiTuongTapHopChiPhi);
                commandParameters[0x12] = DBHelper.createParameter("@TenDoiTuongTapHopChiPhi", DbType.Int64, ParameterDirection.Input, this.mTenDoiTuongTapHopChiPhi);
                commandParameters[0x13] = DBHelper.createParameter("@KhoaThanhPham", DbType.Int64, ParameterDirection.Input, this.mKhoaThanhPham);
                commandParameters[0x14] = DBHelper.createParameter("@TenThanhPham", DbType.Int64, ParameterDirection.Input, this.mTenThanhPham);
                if (DBHelper.ExecuteNonQuery(modGeneral.ConnectionString, CommandType.StoredProcedure, "ST_sp_NhapKhoChiTietDichVu", commandParameters) > 0)
                {
                    return true;
                }
                flag = false;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                flag = false;
                ProjectData.ClearProjectError();
                return flag;
                ProjectData.ClearProjectError();
            }
            return flag;
        }

        public double DonGia
        {
            get
            {
                return this.mDonGia;
            }
            set
            {
                this.mDonGia = value;
            }
        }

        public double DonGiaNT
        {
            get
            {
                return this.mDonGiaNT;
            }
            set
            {
                this.mDonGiaNT = value;
            }
        }

        public string Khoa
        {
            get
            {
                return this.mKhoa;
            }
            set
            {
                this.mKhoa = value;
            }
        }

        public string KhoaDichVu
        {
            get
            {
                return this.mKhoaDichVu;
            }
            set
            {
                this.mKhoaDichVu = value;
            }
        }

        public string KhoaPhieuNhap
        {
            get
            {
                return this.mKhoaPhieuNhap;
            }
            set
            {
                this.mKhoaPhieuNhap = value;
            }
        }

        public string KhoaTKchiPhi
        {
            get
            {
                return this.mKhoaTKChiPhi;
            }
            set
            {
                this.mKhoaTKChiPhi = value;
            }
        }

        public string KhoaDoiTuongTapHopChiPhi
        {
            get
            {
                return this.mKhoaDoiTuongTapHopChiPhi;
            }
            set
            {
                this.mKhoaDoiTuongTapHopChiPhi = value;
            }
        }

        public string TenDoiTuongTapHopChiPhi
        {
            get
            {
                return this.mTenDoiTuongTapHopChiPhi;
            }
            set
            {
                this.mTenDoiTuongTapHopChiPhi = value;
            }
        }

        public string KhoaThanhPham
        {
            get
            {
                return this.mKhoaThanhPham;
            }
            set
            {
                this.mKhoaThanhPham=value;
            }
        }

        public string TenThanhPham
        {
            get
            {
                return this.mTenThanhPham;
            }
            set
            {
                this.mTenThanhPham = value;
            }
        }

        public string MaDichVu
        {
            get
            {
                return this.mMaDichVu;
            }
            set
            {
                this.mMaDichVu = value;
            }
        }

        public double SoLuong
        {
            get
            {
                return this.mSoLuong;
            }
            set
            {
                this.mSoLuong = value;
            }
        }

        public string TenDichVu
        {
            get
            {
                return this.mTenDichVu;
            }
            set
            {
                this.mTenDichVu = value;
            }
        }

        public double TienBan
        {
            get
            {
                return this.mTienBan;
            }
            set
            {
                this.mTienBan = value;
            }
        }

        public double TienBanNT
        {
            get
            {
                return this.mTienBanNT;
            }
            set
            {
                this.mTienBanNT = value;
            }
        }

        public double TienChietKhau
        {
            get
            {
                return this.mTienChietKhau;
            }
            set
            {
                this.mTienChietKhau = value;
            }
        }

        public double TienChietKhauNT
        {
            get
            {
                return this.mTienChietKhauNT;
            }
            set
            {
                this.mTienChietKhauNT = value;
            }
        }

        public double TienThue
        {
            get
            {
                return this.mTienThue;
            }
            set
            {
                this.mTienThue = value;
            }
        }

        public double TienThueNT
        {
            get
            {
                return this.mTienThueNT;
            }
            set
            {
                this.mTienThueNT = value;
            }
        }

        public int TyLeChietKhau
        {
            get
            {
                return this.mTyLeChietKhau;
            }
            set
            {
                this.mTyLeChietKhau = value;
            }
        }

        public int TyLeThue
        {
            get
            {
                return this.mTyLeThue;
            }
            set
            {
                this.mTyLeThue = value;
            }
        }
    }
}

